<template>
  <div class="card" :class="cardData.cardType" @click="clickCard">
    <div class="left-icon" :style="'background-image:url('+ calcIconUrl +');'"></div>
    <div class="right-btn">
      <div class="refuse-bin" v-if="dakaData._id" @click="delDaka(dakaData._id)"></div>
      <div class="three-node" v-else>
          <div class="node"></div>
          <div class="node"></div>
          <div class="node"></div>
      </div>
    </div>
    <div class="title">{{ cardData.title }}</div>
    <div class="total-score" v-if="cardData && cardData.needScore">
      <span>总分：</span>
      <div class="big-score">{{ dakaData && dakaData.totalScore || '6.5' }}</div>
    </div>
    <div class="detail-score-area" v-if="cardData && cardData.cardType ==='all'">
      <div class="detail-score-list">
        <div class="detail-score-item">听力: {{ dakaData.listeningScore || '6.5' }}</div>
        <div class="detail-score-item">口语: {{ dakaData.speakingScore || '6.5' }}</div>
      </div>
      <div class="detail-score-list">
        <div class="detail-score-item">阅读: {{ dakaData.readingScore || '6.5' }}</div>
        <div class="detail-score-item">写作: {{ dakaData.writingScore || '6.5'}}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },
  computed: {
    calcIconUrl() {
      const chineseMap = {
        listening: "听力",
        speaking: "口语",
        reading: "阅读",
        writing: "写作",
        all: "考试"
      };
      if (!this.cardData.cardType) return "";
      const baseUrl = "http://cdn.ielts.group/";
      return baseUrl + chineseMap[this.cardData.cardType] + "@3x.png";
    }
  },
  props: {
    dakaData: {
      type: Object,
      default: () => {
        return {};
      }
    },
    cardData: {
      type: Object,
      default: () => {
        return {};
      }
    },
    // styleType: {
    //   type: String,
    //   default: ''
    // }
  },
  methods: {
    clickCard() {
      this.$emit("clickCard", {
        dakaData: this.dakaData,
        cardData: this.cardData
      });
    },
    delDaka(id) {
      this.$emit('del', id);
    }
  }
};
</script>

<style lang="less" scoped>
.card {
  width: 121px;
  height: 165px;
  background: #ffabbc;
  box-shadow: 0px 10px 20px 0px rgba(255, 220, 227, 1);
  border-radius: 10px;
  position: relative;
  overflow: hidden;
  flex: none;
  &.reading {
    background: #bc88f7;
    box-shadow: 0px 8px 16px 0px rgba(225, 198, 255, 1);
  }
  &.listening {
    background: #ffd733;
    box-shadow: 0px 8px 16px 0px rgba(255, 236, 158, 1);
  }
  &.writing {
    background: #678aff;
    box-shadow: 0px 8px 16px 0px rgba(175, 193, 255, 1);
  }
  &.speaking {
    background: #50e3c2;
    box-shadow: 0px 8px 16px 0px rgba(177, 255, 217, 1);
  }
  .left-icon {
    width: 20px;
    height: 20px;
    position: absolute;
    top: 9px;
    left: 8px;
    background-size: 100%;
    background-position: center center;
  }
  .right-btn {
    width: 40px;
    height: 40px;
    border-radius: 0 0 0 40px;
    background: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    right: 0;
    top: 0;
    position: absolute;
  }
  .refuse-bin {
    height: 14px;
    width: 14px;
    background: url("http://cdn.ielts.group/%E5%9E%83%E5%9C%BE%E6%A1%B6%403x.png")
      center center no-repeat;
    background-size: 100%;
    margin-bottom: 10px;
    margin-left: 5px;
  }
  .three-node {
      display: flex;
      margin-left: 7px;
      margin-bottom: 2px;
    .node {
      width: 2px;
      height: 2px;
      border-radius: 50%;
      background: #3d475c;
      flex: 0 0 none;
    }
    .node + .node {
        margin-left: 6px;
    }
  }
  .title {
    position: absolute;
    width: 77px;
    top: 36px;
    left: 10px;
    font-size: 12px;
    line-height: 17px;
    color: #fff;
    font-weight: 600;
  }
  .total-score {
    position: absolute;
    top: 78px;
    left: 10px;
    width: 43px;
    color: #3d475c;
    font-size: 7px;
    display: flex;
    align-items: center;
    .big-score {
      font-size: 14px;
      font-weight: 600;
    }
  }
  .detail-score-area {
    position: absolute;
    width: 71px;
    top: 107px;
    left: 10px;
    font-size: 7px;
    color: #3d475c;
    .detail-score-list {
      display: flex;
      .detail-score-item + .detail-score-item {
        margin-left: 7px;
      }
    }
    .detail-score-list + .detail-score-list {
      margin-top: 5px;
    }
  }
}
.card + .card {
  margin-left: 16px;
}
</style>